window.onload = function () {
    //手机号
    var tel = document.querySelector('#tel');
    var regtel = /^1[3|5|6|7|8]\d{9}$/;
    //qq号
    var qq = document.querySelector('#qq');
    var regqq = /^[1-9]\d{4,}$/;
    //短信验证
    var msg = document.querySelector('#msg');
    var regmsg = /^\d{6}$/;
    //密码
    var pwd = document.querySelector('#pwd');
    var regpwd = /^[a-zA-Z0-9_-]{6,16}$/;
    regexp(tel, regtel);
    regexp(msg, regmsg);
    regexp(pwd, regpwd);
    regexp(qq, regqq);
    function regexp(ele, reg) {
        ele.onblur = function () {
            if (reg.test(this.value)) {
                console.log('正确');
                this.nextElementSibling.className = 'success';
                this.nextElementSibling.innerHTML = '<i class="success_icon"></i> 格式正确!';
            } else {
                console.log('错误');
                this.nextElementSibling.className = 'error';
                this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 格式不正确，请重新输入！';
            }
        }
    }
}